package com.groupfifteen.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.groupfifteen.dao.SysUserDao;
import com.groupfifteen.entity.SysUserEntity;
import com.groupfifteen.vo.SysUserVo;
import org.springframework.stereotype.Service;

@Service("sysUserService")
public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity>
        implements SysUserService {


    @Override
    public Integer AddSysUser(SysUserEntity sysUserEntity) {
        return baseMapper.insert(sysUserEntity);
    }

    @Override
    public IPage<SysUserEntity> Query(SysUserEntity sysUserEntity, int pageNo, int pageSize) {

        LambdaQueryWrapper<SysUserEntity> query = Wrappers.lambdaQuery();
        query.eq(sysUserEntity.getId() != null, SysUserEntity::getId, sysUserEntity.getId());

        if( pageNo == 0 )
        {
            pageNo = 1;
        }
        if( pageSize == 0 ){
            pageSize = 10;
        }

        IPage<SysUserEntity> page = Page.of(pageNo, pageSize);

        return baseMapper.selectPage(page, query);
    }

    @Override
    public IPage<SysUserEntity> Query(SysUserVo sysUserVo) {
//        LambdaQueryWrapper<SysUserEntity> query = Wrappers.lambdaQuery();
//        query.eq(sysUserVo.getId() != null, SysUserEntity::getId, sysUserVo.getId());
//
//
//
//        IPage<SysUserEntity> page = Page.of(pageNo, pageSize);

        return null;
    }
}
